package com.example.springboot1.service.iml;

import com.example.springboot1.dao.UserMapper;
import com.example.springboot1.entity.User;
import com.example.springboot1.service.Registerservice;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Registerserviceiml implements Registerservice {
    @Autowired
    UserMapper userMapper;
    @Override
    public int registerservice(User user) {
        if(userMapper.selectByUsername(user.getUsername())!=0){
            throw new RuntimeException("用户已存在");
        }
        return userMapper.insertUser(user);
    }
}
